package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 服务积分
 * @author EDY
 */
public class ServicePointsConstant {


    /**
     * 提现方式
     * 0：银行
     * 1：微信
     * 2：支付宝
     * 3：公益积分
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum WithdrawWay implements IntegerEnum<Integer> {

        BANK(0, "银行"),
        WECHAT(1, "微信"),
        ALIPAY(2, "支付宝"),
        WELFARE_INTEGRAL(3, "公益积分"),

        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        WithdrawWay(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ServicePointsConstant.WithdrawWay getByCode(int code) {
            for (ServicePointsConstant.WithdrawWay value : ServicePointsConstant.WithdrawWay.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }
}
